package com.panshi.modules.controller;

import com.panshi.api.HomeApi;
import com.panshi.po.Shox;
import com.panshi.modules.service.ISearchService;

import com.panshi.utils.TimeBean;
import com.panshi.vo.HomeQueryVO;
import com.panshi.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

@RestController
@RequestMapping("home-api")
public class HomeController implements HomeApi {

    @Autowired
    private ISearchService searchService;

    /*
    * 推荐，最新，最热
    * */
    public Result<Set<Shox>> initHome(@RequestBody HomeQueryVO homeQueryVO){

        Result<Set<Shox>> result = new Result();
        Integer current = homeQueryVO.getCurrent()==null ? 1 : homeQueryVO.getCurrent();
        int page = (current- 1) * 10;
        Integer type = homeQueryVO.getType();
        Set<Shox> shoxes = null;
        if(type==null || type == 10){
            shoxes = searchService.tian(page);
        }else if(type == 15){
            shoxes = searchService.tian1(page);
        }else if(type == 20){
            shoxes = searchService.tian2(page);
        }
        result.ok().setData(shoxes);
       return result;
    }
}
